var basePath="http://localhost:8080/";
$(function(){
	getStatusInfoList();
});

function getStatusInfoList(){
	$.ajax({
		url:basePath+'OrderStatus/listAll',
		method:'get',
		dataType:'json',
		data:{},
		success:function(data){
			if(data.code==0){
				setStatusList(data.row);
			}
			else
				alert("获取信息列表失败")
		},
		error:function(){
			alert("获取信息列表出错")
		},
	});
}
function setStatusList(list){
	$('#statusTab tbody').empty();
	totalCount=list.length;
	currentIndex=1;
	totalPage=Math.ceil(totalCount/pageSize);
	
	$("#totalPages").html(totalPage);
	$("#currentIndex").html(currentIndex);
	
	var html="";
	for(var i=0;i<list.length;i++){
		var item=list[i];
		html+='<tr id="tr'+i+'" class="problem" style="display:none"><td>'+item.fixOrderId+'</td><td>'
		+item.operation+'</td><td>'+item.remark+'</td><td>'+item.createTime+'</td><tr>';
	}
	$('#statusTab tbody').html(html);
	//显示第一页数据
    for(var i=0;i<pageSize;i++){
        var tr=$("#tr"+i);
        if(tr.length>0)
            tr.show();
    }
}
//分页设置
var pageSize=8;
var currentIndex;
var totalCount=0;
var totalPage;
function lastPage() {
	   if(currentIndex-1<1)
	       alert("当前为第一页")
	   else{
	       currentIndex--;
	       showPage(currentIndex);
	   }
}
function nextPage() {
    if(currentIndex+1>totalPage)
        alert("当前为最后一页")
    else{
        currentIndex++;
        showPage(currentIndex);
    }
}
function showPage(index) {
    $("#currentIndex").html(index);
    $(".problem").hide();
    for (var i =(index-1)*pageSize; i<totalCount&&i<index*pageSize; i++) {
        $("#tr"+i).show();
    }
}	